package com.anysoft.controller;

import com.anysoft.model.UserBean;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;

@Controller
@RequestMapping("/taglib")
public class TaglibController {
    @RequestMapping("/jstlcore")
    public String jstlCore(HttpServletRequest request, Model model) {
        ArrayList<UserBean> users = new ArrayList<UserBean>();
        UserBean ub1 = new UserBean("zhao", 20);
        UserBean ub2 = new UserBean("qian", 40);
        UserBean ub3 = new UserBean("sun", 60);
        UserBean ub4 = new UserBean("li", 80);
        users.add(ub1);
        users.add(ub2);
        users.add(ub3);
        users.add(ub4);
        request.setAttribute("usersKey", users);
        model.addAttribute("cif", 123);
        model.addAttribute("choose", 3);
        return "jstlcore";
    }

    @RequestMapping("/jstlfunctions")
    public String jstlFunctions(Model model) {
        String[] arr = {"q", "w", "e", "r"};
        model.addAttribute("myArr", arr);
        return "jstlfunctions";
    }
}
